import REST from "@module/Rest";
import "./style.scss";

class Notice extends React.Component {
    constructor() {
        super();
        this.state = {
            message: "",
            isShowNotice:true
        };
    }

    componentDidMount() {
        this.getNotice();
    }

    getNotice() {
        let url = `/suppliers/bulletin/one`;
        let params = {
            position: "top",
            suppId: $state.params.suppId
        };
        REST.post(url, params).then(
            data => {
                if (data.msg == "success") {
                    this.setState({
                        message: data.data && data.data.content
                    });
                }
            },
            error => {}
        );
    }

    render() {
        const { message, isShowNotice } = this.state;
        return (
            (message &&
            isShowNotice) && (
                <div className="rj_notice-wp">
                    <span>{message}</span>
                    <span
                        className="zen_f-right zen_p-r-10 zen_cur-p"
                        onClick={() => {
                            this.setState({ isShowNotice: false });
                        }}
                    >
                        X
                    </span>
                </div>
            )
        );
    }
}

export default Notice;
